let express = require("express");
let app = express();
let Router = require("./src/router");

app.use("/uploads", express.static("public"));
app.use(express.json({ type: "application/json" }));
app.use(express.urlencoded({ extended: true }));
// 权限控制
app.use((req, res, next) => {
	res.header("Access-Control-Allow-Origin", "*"); // 允许所有源（生产环境慎用）
	res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); // 允许的HTTP方法
	res.header("Access-Control-Allow-Headers", "Content-Type, Authorization,"); // 允许的自定义头1
	next();
});
app.use(Router);

app.listen(3000, () => {
	console.log("Server is running on http://localhost:3000");
});
